package com.infoauto.opc.gateway.messages.configuration;

import com.infoauto.opc.gateway.messages.factory.MqttFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//MQTT协议配置
@Configuration
@ConditionalOnExpression("'${mqtt.broker.serverUri:}'!=''")
public class MqttConfiguration {

    @Value("${mqtt.broker.serverUri:}")
    private String serverUris;

    @Value("${mqtt.broker.userName:}")
    private String userName;

    @Value("${mqtt.broker.password:}")
    private String password;

    @Bean
    public MqttFactory mqttFactory() {
        return new MqttFactory(serverUris, userName, password);
    }
}
